f90_unix_dirent: Unix Directory-reading Operations Module

Contents

Name

f90_unix_dirent - Module of Unix directory-reading operations

Usage

USE F90_UNIX_DIRENT

This module contains part of a Fortran API to functions detailed in ISO/IEC 9945-1:1990 Portable Operating System Interface (POSIX) - Part 1: System Application Program Interface (API) [C Language].

The functions in this module are from Section 5.1.2: Directory Operations

Error handling is described in F90_UNIX_ERRNO. Note that for procedures with an optional ERRNO argument, if an error occurs and ERRNO is not present, the program will be terminated.

Synopsis

Procedures
CLOSEDIR, OPENDIR, READDIR, REWINDDIR

Procedure Description

  SUBROUTINE CLOSEDIR(DIRUNIT,ERRNO)

  INTEGER,INTENT(IN) :: DIRUNIT
  INTEGER,OPTIONAL,INTENT(OUT) :: ERRNO
Close a directory stream that was opened by OPENDIR.

If DIRUNIT does not refer to an open directory stream, error EBADF (see F90_UNIX_ERRNO) is raised.

  SUBROUTINE OPENDIR(DIRNAME,DIRUNIT,ERRNO)

  CHARACTER*(*),INTENT(IN) :: DIRNAME
  INTEGER,INTENT(OUT) :: DIRUNIT
  INTEGER,OPTIONAL,INTENT(OUT) :: ERRNO
Opens a directory stream, returning a handle to it in DIRUNIT.

Possible errors include EACCES, ENAMETOOLONG, ENOENT, ENOTDIR, EMFILE and ENFILE (see F90_UNIX_ERRNO).

  SUBROUTINE READDIR(DIRUNIT,NAME,LENNAME,ERRNO)

  INTEGER,INTENT(IN) :: DIRUNIT
  CHARACTER*(*),INTENT(OUT) :: NAME
  INTEGER,INTENT(OUT) :: LENNAME
  INTEGER,OPTIONAL,INTENT(OUT) :: ERRNO
Reads the first/next directory entry. The name of the file is placed into NAME, blank-padded or truncated as appropriate if the length of the file name differs from LEN(NAME). The length of the file name is placed in LENNAME. Note: The maximum file name length is available from SYSCONF; enquiry SC_NAME_MAX.

If there are no more directory entries, NAME is undefined and LENNAME is negative.

If DIRUNIT is not a directory stream handle produced by OPENDIR, or has been closed by CLOSEDIR, error EBADF (see F90_UNIX_ERRNO) is raised.

  SUBROUTINE REWINDDIR(DIRUNIT,ERRNO)

  INTEGER,INTENT(IN) :: DIRUNIT
  INTEGER,OPTIONAL,INTENT(OUT) :: ERRNO
Rewinds the directory stream so that the next call to READDIR on that stream will return the name of the first file in the directory.

See Also

f90_unix_errno(3), f95(1), intro(3), nag_modules(3).

Bugs

Please report any bugs found to "support@nag.co.uk" or "infodesk@nag.com", along with any suggestions for improvements.